<template>
  <div>
    <a-card :bordered="false">
      <f-search-form @searchHandler="searchHandler">
        <f-search-form-item label="WBS" name=""/>
        <f-search-form-item label="项目类别" name="typps"  slot="advanced"/>
        <f-search-form-item label="单位" name="meeht"  slot="advanced"/>
      </f-search-form>
      <f-table ref="table" rowKey="" :scroll="{x:auto}" :columns="columns" :exportBtn="false" :multiple="false"
               :width="600"
               :operator="operator" :params="queryParam" :api="api.bwbs">
        <span slot="action" slot-scope="text, record">
        </span>
      </f-table>
    </a-card>
  </div>
</template>
<script>
  import api from './js/api'

  export default {
    name: 'BwbForm',
    props: {
      detailsParams: {}
    },
    data() {
      let me = this
      let operator = []
      operator.push({
        name: '导出WBS数据',
        icon: '',
        that: this,
        handler: function(table, that) {
          // let columns = table.getExportColumns(that.columns)
          // columns.push({ name: '是否新增', isStatistics: '0', key: 'isAdd' })
          // that.detailsParams['columns'] = JSON.stringify(columns)
          that.exportWbs()
        }
      })
      //操作按钮
      return {
        refs: this.$refs,
        api: Object.assign(api, this.api),
        //列表初始化查询参数
        queryParam: {},
        // 表头
        columns: [
          {
            title: 'wbs',
            width: '180',
            align: 'center',
            sorter: (a, b) => a.posid.length - b.posid.length,
            dataIndex: 'posid'
          },
          {
            title: '版本',
            width: '50',
            align: 'center',
            sorter: (a, b) => a.versn.length - b.versn.length,
            dataIndex: 'versn'
          },
          {
            title: '项目类别',
            width: '50',
            align: 'center',
            sorter: (a, b) => a.typps.length - b.typps.length,
            dataIndex: 'typps'
          },
          {
            title: '数量',
            width: '50',
            align: 'center',
            sorter: (a, b) => a.menge.length - b.menge.length,
            dataIndex: 'menge'
          },
          {
            title: '单位',
            width: '50',
            align: 'center',
            sorter: (a, b) => a.meeht.length - b.meeht.length,
            dataIndex: 'meeht'
          },
          {
            title: '描述',
            width: '200',
            align: 'center',
            sorter: (a, b) => a.ltext.length - b.ltext.length,
            dataIndex: 'ltext'
          },
          {
            title: '单价',
            width: '50',
            align: 'center',
            sorter: (a, b) => a.lpreis.length - b.lpreis.length,
            dataIndex: 'lpreis'
          },
          {
            title: '价格单位',
            width: '50',
            align: 'center',
            sorter: (a, b) => a.lpeinh.length - b.lpeinh.length,
            dataIndex: 'lpeinh'
          },
          {
            title: '成本要素',
            width: '100',
            align: 'center',
            sorter: (a, b) => a.kstar.length - b.kstar.length,
            dataIndex: 'kstar'
          }
        ]
        ,operator: operator
      }
    },
    methods: {
      getFormItem() {
        return {
          // ysId: ''
        }
      },
      //表单赋值
      setData(data) {
        // this.$refs.form.resetFields()
        // this.formItem = this.getFormItem()
        // if (data && data.ysId) {
        //   const params = {
        //       ysId: data.ysId
        //   }
        //   this.refs['form'].getDetails(params, (data) => {
        //      this.formItem = data
        //      this.loaded = true
        //   })
        //   this.isAdd = false
        // } else {
        //   this.loaded = true
        // }
      },
      //提交表单
      handleSubmit(callback) {
        // this.$refs.form.submit({  }, callback)
      },
      exportWbs() {
        let that = this
        that.http.exportExcel(that, {
          url: that.api.bwbs.exportWbsUrl,
          data: that.detailsParams
        })
      }
    },
    created() {
      this.queryParam = this.detailsParams
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
